<?php
//ini buat list job
//ditampilin berdasarkan parameter yg diterima : ditampilkan/diurutkan berdasarkan apa? latest? atau by job's attribute?
//parameter : array of criteria ($criteria)
	$this->pageTitle = "TimeBay - Browse pekerjaan";
	
	/*$conn = Yii::app()->db;
	$cmd = $conn->createCommand("Select * from job");
	
	$data = $cmd->query();
	
	$data->bindColumn(4,$nama);
	
	while($data->read()!==false)
	{
		echo "nama pekerjaan : ". $nama. "<br/>";
	}
	
	*/
	
    // $this->widget('zii.widgets.CListView', array(
        // 'dataProvider'=>$model->searchSortBy("start_date DESC", array()),
        // 'itemView'=>'_jobPosting',
    // ));
	
	
	
	?>
<h5>Cari Pekerjaan Sesuai Kriteria</h5>
<hr/>
	<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'job-searchResults-form',
	'enableAjaxValidation'=>false,
)); ?>


	<?php echo $form->errorSummary($model); ?>
	
	

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name'); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row_startDate">
		<?php echo $form->labelEx($model,'reward min'); ?>
		Rp.<?php echo $form->textField($model,'reward'); ?>
		<?php echo $form->error($model,'reward'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'rewardMax'); ?>
		s.d Rp.<?php echo $form->textField($model,'rewardMax'); ?>
		<?php echo $form->error($model,'rewardMax'); ?>
	</div>

	<div class="row_startDate">
		<?php echo $form->labelEx($model,'start_date'); ?>
		<?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name'=>'Job[start_date]', // Name of the datepicker form field.
                        //'id ' => 'Job_start_date',
                        // additional javascript options for the date picker plugin
                        'options'=>array(
                            'showAnim'=>'fold',
                            'type' => 'timestamp',
                            'altField'=>'#start_date_picker', // The jQuery selector of the "target" field
                            'altFormat'=>'yy-mm-dd hh:ii:ss', // If you want the target field to have a different format
                            'dateFormat' => 'yy-mm-dd hh:ii:ss'
                        ),
                        'htmlOptions'=>array(
                            'style'=>'height:20px;',
                        ),
                    ));
                ?>
                <?php //echo $form->textField($model,'start_date'); ?>
		<?php echo $form->error($model,'start_date'); ?>
	</div>

	<div class="row_startDateMax">
		<?php echo $form->labelEx($model,'start_dateMax'); ?>
		<?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name'=>'Job[start_dateMax]', // Name of the datepicker form field.
                        //'id ' => 'Job_start_date',
                        // additional javascript options for the date picker plugin
                        'options'=>array(
                            'showAnim'=>'fold',
                            'type' => 'timestamp',
                            'altField'=>'#start_dateMax_picker', // The jQuery selector of the "target" field
                            'altFormat'=>'yy-mm-dd hh:ii:ss', // If you want the target field to have a different format
                            'dateFormat' => 'yy-mm-dd hh:ii:ss'
                        ),
                        'htmlOptions'=>array(
                            'style'=>'height:20px;',
                        ),
                    ));
                ?>
                <?php //echo $form->textField($model,'start_dateMax'); ?>
		<?php echo $form->error($model,'start_dateMax'); ?>
	</div>

	
	<div class="row buttons">
		<?php echo CHtml::submitButton('Submit'); ?>
	</div>

<?php $this->endWidget(); ?>
<hr/>
 <?php
        if ($type == "latest"){
		?>
		<h2>Daftar Pekerjaan Terbaru</h2>
		<?php
	}
	else if ($type == "criteria"){
		?>
		<a href="<?php Yii::app()->request->baseUrl. "/index.php?r=browse/viewlatest"; ?>"><< Daftar Pekerjaan terbaru</a>
                <h2>Hasil Pencarian Pekerjaan</h2>
                
		<?
	}
            ?>

</div><!-- form -->

<?
	$model2 = Job::model()->findAll($cond);
	for($i=0; $i < count($model2); $i++){
	?>
		<hr/>
		<?php echo CHtml::link($model2[$i]->name, Yii::app()->request->baseUrl. "/index.php?r=job/view/id/". $model2[$i]->id); ?><br/>
		<?php echo $model2[$i]->formattedReward ?><br/>
		<?php echo $model2[$i]->start_date; ?> - <?php echo $model2[$i]->end_date; ?><br/>
		<?php echo count($model2[$i]->applications) ?> pelamar<br/>
		<?php echo "Status lamaran : " . ConstantsLookUp::getJobStatus($model2[$i]->status); ?>
		<br/><br/>
	<?php
	}
	//$data->bindColumn(1,$nama);
	
?>
